//
//  NoIntegral.m
//  intelligent
//
//  Created by Ace Portgas on 2024/3/28.
//

#import "NoIntegral.h"
@interface NoIntegral()
@property (nonatomic,strong) UIButton * closeBtn;
@property (nonatomic,strong) UIButton * okBtn;
@property (nonatomic,strong) UIImageView * imageView;
@property (nonatomic,strong) UILabel * titleLabel;
@end
@implementation NoIntegral

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.6];
        
        _imageView = [[UIImageView alloc]init];
        _imageView.image = SQGetImage(@"背景2");
        [self addSubview:_imageView];
        [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_offset(CGSizeMake(320, 240));
            make.centerX.mas_equalTo(self.mas_centerX);
            make.top.mas_equalTo(self).offset(204);
        }];
        
        _titleLabel = [UILabel new];
        _titleLabel.text = SQNSLocalString(@"制图积分不足\n充值制图积分");
        _titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
        _titleLabel.textColor = [UIColor colorWithHexString:@"#333333"];
        _titleLabel.numberOfLines = 0;
        [self addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self.imageView.mas_centerX);
            make.bottom.mas_equalTo(self.imageView.mas_bottom).offset(-64);
        }];
        _titleLabel.lineSpace = 20;
        [self.titleLabel getLableSizeWithMaxWidth:200];
        _okBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_okBtn addTarget:self action:@selector(clickOKBtn) forControlEvents:UIControlEventTouchUpInside];
        [_okBtn setTitle:SQNSLocalString(@"去充值") forState:UIControlStateNormal];
        [_okBtn setTitleColor:[UIColor colorWithHexString:@"#FDCF4A"] forState:UIControlStateNormal];
        _okBtn.backgroundColor = [UIColor colorWithHexString:@"#000000"];
        _okBtn.layer.cornerRadius = 24;
        [self addSubview:_okBtn];
        [_okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_offset(CGSizeMake(246, 48));
            make.centerX.mas_equalTo(self.mas_centerX);
            make.top.mas_equalTo(self.imageView.mas_bottom).offset(-25);
        }];
        
        _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_closeBtn addTarget:self action:@selector(clickCloseBtn) forControlEvents:UIControlEventTouchUpInside];
        [_closeBtn setImage:SQGetImage(@"取消") forState:UIControlStateNormal];
        [self addSubview:_closeBtn];
        [_closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self.mas_centerX);
            make.top.mas_equalTo(self.okBtn.mas_bottom).offset(34);
            make.size.mas_offset(CGSizeMake(40, 40));
        }];
    }
    return self;
}

-(void)clickCloseBtn{
    if (self.ClickCancelBlock) {
        self.ClickCancelBlock();
    }
}

-(void)clickOKBtn{
    if (self.ClickOKBlock) {
        self.ClickOKBlock();
    }
}

@end
